<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>处理很长类中的一个值</title>
</head>
<body>
<div class="nong myblue weixi" id="nong">
    这个div类很长
</div>
<script>
    var divList = document.getElementById("nong").className.split(" ");
    var i=0,
        divLength=divList.length;
    for(i;i<divLength;i++){
        console.log(i);
        if(divList[i]=="myblue"){
//            divList.splice(i,1);
            break;  //用break就在匹配到后就跳出循环，优化了一点点性能
        }
    }
    divList.splice(i,1);
    console.log(divList);

//    这里有两种方案
//    document.getElementById("nong").className = divList.toString().replace(/,/," ");
    document.getElementById("nong").className = divList.join(" ");
</script>
</body>
</html>